<?php

namespace app\rest\model;

use think\Model;

class User extends Model
{
    protected $table = 'hc_user';
    protected $pk = 'id';


    public function setPass($pass)
    {
//        return md5($pass);
//        return md5(md5($pass));
//        return hash('md5', $pass);
//        return hash('sha1', $pass);
//        return hash('sha256', $pass);
//        dump(hash_algos());
//        return hash( 'sha512', $pass);
//        return hash( 'haval160,4', $pass);

        // 不易破解的密码  盐值
        return password_hash($pass, PASSWORD_DEFAULT);
    }


    public function checktPass($id, $pass)
    {
        $user = User::get($id);
        $hashPass = $user->pass;

        dump($hashPass);
        dump($pass);

        return password_verify($pass, $hashPass);
    }


}
